/**
 * Created by lixiaodi on 2019/04/15 0027.
 */

mini.parse();
var grid = mini.get('datagrid1');
//页面初始化
$(function(){
	httpRequest();
});
//保存数据(点击确定时)
function SaveData() {
    //得到数据
	var row = grid.getSelected();
	console.log(row);
//	$.ajax({
//        url: ajaxUrl + "",
//        type: 'POST',
//        data: row,
//        contentType : "application/json",
//        success: function (data) {
//            CloseWindow("save");
//        },
//        error: function (jqXHR, textStatus, errorThrown) {
//            //alert(jqXHR.responseText);
//            CloseWindow();
//        }
//    });	    
}
//关闭子页面
function CloseWindow(action) {
	console.log(action,'关闭子页面时候的action');
    if (action == "close" && form.isChanged()) {
        if (confirm("数据被修改了，是否先保存？")) {
            return false;
        }
    }
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
}
//确定
function onOk(e) {
    SaveData();
}
//取消
function onCancel(e) {
    CloseWindow("cancel");
}
//数据请求
function httpRequest(){
	$.ajax({
        url: ajaxUrl + "/modular/list.do",
        type:"post",
        success: function (data) {
        	var processData = data.data;
        	for(var i = 0; i < processData.length; i++){
        		//日期格式化
        		if(processData[i].createDate){
        			processData[i].createDate = formatDate(processData[i].createDate);
        		}else{
        			processData[i].createDate = '';
        		}
        	}
        	grid.setData(modularData);
        },
        error:function(data){
            mini.alert(data.message);
        }
    });
}
